/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ncf;
import java.sql.*;
/**
 *
 * @author 15057382-3
 */

 
 
/** 
  
 */
   public class Conectate { 
   static String bd = "NOMBRE_BASE_DE_DATOS"; 
   static String login = "USUARIO"; 
   static String password = "PASSWORD"; 
   static String url = "jdbc:mysql://localhost/"+bd; 
 
   Connection conn = null; 
     
   public Conectate() { 
      try{          
         Class.forName("com.mysql.jdbc.Driver");          
         conn = DriverManager.getConnection(url,login,password); 
         if (conn!=null){ 
            System.out.println("Conección a base de datos "+ bd +". listo"); 
         } 
      }catch(SQLException e){ 
         System.out.println(e); 
      }catch(ClassNotFoundException e){ 
         System.out.println(e); 
      } 
   } 
    
   public Connection getConnection(){ 
      return conn; 
   } 
 
   public void desconectar(){ 
      conn = null; 
   } 
}